package com.hello.booksale.dao;

import com.hello.booksale.entity.UserEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {

    @Select("SELECT * FROM `user`")
    List<UserEntity> selectAllUsers();
 @Select("SELECT user_password FROM `user` WHERE user_id=#{userId}")
    String selectUserPassword(@Param("userId") int userId);
 @Select("SELECT * FROM `user` WHERE user_name=#{userName}")
    UserEntity selectUserName(@Param("userName") String userName);
 @Insert("INSERT INTO `user`(user_name,user_password) VALUES(#{userName},#{userPassword})")
    void insertUser(UserEntity userEntity);

 @Delete("DELETE FROM `user` WHERE user_id=#{userId}")
    void deleteUserById(@Param("userId") int userId);

 @Update("UPDATE `user` SET user_name=#{userName},user_password=#{userPassword} WHERE user_id=#{userId}")
    void updateUserById(UserEntity userEntity);

}
